<template>
	<view>
		<view
			style="width: 85%;margin: 30rpx auto;background-color: #75dccb;padding: 30rpx;border-radius: 30rpx;color: #fff;">
			<view style="display: flex;justify-content: space-between;align-items: center;">
				<view style="display: flex;justify-content: flex-start;line-height: 60rpx;align-items: center;">
					<image :src="user.avatarUrl" style="width: 150rpx;height: 150rpx;margin-right: 20rpx;"
						mode="aspectFill">
					</image>
					<text>{{user.nickname}}<br /><text style="font-size: 20rpx;">爱护环境人人有责</text></text>
				</view>
				<text @click="toSignin">签到</text>
			</view>
			<view style="display: flex;justify-content: space-around;text-align: center;margin-top: 40rpx;">
				<view class="item">
					<text>￥{{user.profit}}</text><br />
					<text>累计收益</text>
				</view>
				<view class="item">
					<text>{{user.num}}</text><br />
					<text>回收次数</text>
				</view>
				<view class="item">
					<text>{{user.integral}}</text><br />
					<text>积分</text>
				</view>
			</view>
		</view>
		<u-cell-group>
			<u-cell @click="topage" name="0" :isLink="true" icon="star" title="积分记录"></u-cell>
			<u-cell @click="topage" name="1" :isLink="true" icon="coupon" title="积分兑换记录"></u-cell>
			<u-cell @click="topage" name="2" :isLink="true" icon="integral" title="我的贡献"></u-cell>
			<u-cell @click="topage" name="3" :isLink="true" icon="red-packet" title="收入记录"></u-cell>
			<u-cell @click="topage" name="4" :isLink="true" icon="map" title="地址管理"></u-cell>
			<u-cell @click="topage" name="5" :isLink="true" icon="setting" title="设置"></u-cell>
		</u-cell-group>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user:{}
			}
		},
		onLoad() {
			this.getUserInfo()
		},
		methods: {
			getUserInfo(){
				uni.getStorage({
					key:'user',
					success: (res) => {
						console.log(res);
						this.user=res.data
						this.user.num=0
					}
				})
			},
			toSignin(){
				uni.navigateTo({
					url: './signin'
				})
			},
			topage(e) {
				console.log(Number(e.name));
				switch (Number(e.name)) {
					case 0:
						// 积分记录
						uni.navigateTo({
							url: './integralRecord'
						})
						break;
					case 1:
						// 积分兑换记录
						uni.navigateTo({
							url: './rointsExchangeRecord'
						})
						break;
					case 2:
						// 我的贡献
						uni.navigateTo({
							url: './myContribution'
						})
						break;
					case 3:
						// 收入记录
						uni.navigateTo({
							url: './revenueRecords'
						})
						break;
					case 4:
						// 地址管理
						uni.navigateTo({
							url: './address'
						})
						break;
					case 5:
						// 设置
						uni.navigateTo({
							url: '../setup/setup'
						})
						break;
				}
			}
		}
	}
</script>

<style>
	.item {
		width: 100%;
	}
</style>
